\chapter*{Interfaces}
\section*{Incoming Communication Module}
\subsection*{receiveData}
\paragraph{Interface Identity} iTrameValidator - receiveData.
\paragraph{Resources provided} This interface provides the remote modules the necessary mechanism to send trames to ReMeS.
\begin{itemize}
\item Syntax: void receiveData(Data d)
\item Semantics: receiveData provides the functionality for remote monitoring and control modules to send trames to ReMeS. This will be done in some sort of Data format, for which the format is not strict specified.
\end{itemize}

\section*{Outgoing Communication Module}
\subsection*{sendCommand}
\paragraph{Interface Identity} iOutgoingModule - sendCommand.
\paragraph{Resources provided} This interface gives the components the opportunity to send commands to the remote modules.
\begin{itemize}
\item Syntax: void sendCommand(Command c)
\item Semantics: A command object is send to the Outgoing Communication Module. The Command object consists of the command (e.g. ack, valve shutdown, reconfigure, ...) and of the remote module/valve, the information necessary to send the command (e.g. module id).
\end{itemize}
\subsection*{sendNotification}
\paragraph{Interface Identity} iOutgoingModule - sendNotification.
\paragraph{Resources provided} This interface gives the possibility to send notifications to customers and ReMeS operators.
\begin{itemize}
\item Syntax: void sendNotification(Notification n)
\item Semantics: The notification command contains everything that is needed for the Outgoing Communication Module to send the notification. It has the text, the recipient(s) information and the channel information.
\end{itemize}

\section*{Alarm Handler}
\subsection*{processAlarmTrame}
\paragraph{Interface Identity} iAlarmHandler - processAlarmTrame.
\paragraph{Resources provided} This interface accepts an alarm trame and processes it. It notifies the user, closes the valve and stores the alarm trame in the database.
\begin{itemize}
\item Syntax: void processAlarmTrame(Trame t)
\item Semantics: The alarm Trame is stored in the database, the customer is notified and if necessary the valve is closed. When there is no valve to close, an ack is send in stead. 
\end{itemize}

\section*{Notification Handler}
\subsection*{sendAlarmNotification}
\paragraph{Interface Identity} iNotificationHandler - sendAlarmNotification.
\paragraph{Resources provided} This interface sends an alarm notification to a customer.
\begin{itemize}
\item Syntax: void sendAlarmNotifcation(Module m, Details d)
\item Semantics: An alarm notification is created for the customer of the Module with any additional Details.
\end{itemize}
\subsection*{sendIssueNotification}
\paragraph{Interface Identity} iNotificationHandler - sendIssueNotification.
\paragraph{Resources provided} This interface sends an issue notification to a ReMeS operator.
\begin{itemize}
\item Syntax: void sendIssueNotification(Details d)
\item Semantics: Since the issue is not send to a customer, but to a ReMeS operator, there is only the need to send Details about the issue. The Operator will be retrieved first from the NotificationDB, and together with the issue it will be packed into a Notification. In this way it can be forwarded to the outgoing communication module.
\end{itemize}
\subsection*{sendAnomalyNotification}
\paragraph{Interface Identity} iNotificationHandler - sendAnomalyNotification.
\paragraph{Resources provided} This interface sends an anomaly notification to a customer.
\begin{itemize}
\item Syntax: void sendAnomalyNotification(Module m, Details d)
\item Semantics: An anomaly notification is created for the Alarm Recipients of the Module with any additional Details about the anomaly. Similarly, also a notification is sent to the Customer who is the owner of the Module.
\end{itemize}
\subsection*{sendInfoNotification}
\paragraph{Interface Identity} iNotificationHandler - sendInfoNotification.
\paragraph{Resources provided} This interface is to let a customer know of a price update or change or to let him know of other details or important notifications.
\begin{itemize}
\item Syntax: void sendInfoNotification(Customer c, Details d)
\item Semantics: A detailed notification is created for the Customer with Details about the information and in the form of a Notification passed to the Outgoing Communication Module.
\end{itemize}

\section*{Command Sender}
\subsection*{actuateValve}
\paragraph{Interface Identity} iCommandSender - actuateValve.
\paragraph{Resources provided} This interface closes or opens a valve.
\begin{itemize}
\item Syntax: void actuateValve(Module m)
\item Semantics: The Alarm Handler calls this method and passes the Module as an argument. The Module is then used to find the corresponding valve in the database.
\end{itemize}
\subsection*{sendAck}
\paragraph{Interface Identity} iCommandSender - sendAck.
\paragraph{Resources provided} This interface is made to provide acknowledgments to the remote modules for the trames they have send to ReMeS.
\begin{itemize}
\item Syntax: void sendAck(Module m, Trame t)
\item Semantics: An ack command is created based on the Trame (e.g. from some trame identifier) and send to the Module through the Outgoing Communication Module.
\end{itemize}
\subsection*{processConfirmTrame}
\paragraph{Interface Identity} iCommandSender - processConfirmTrame.
\paragraph{Resources provided} This interface is made to provide acknowledgments to the remote modules for the trames they have send to ReMeS.
\begin{itemize}
\item Syntax: void processConfirmTrame(Trame t)
\item Semantics: When a trame is sent to a remote module, ReMeS expects this command to be acknowledged. This is done by a confirmation trame. A trame is sent with success from the moment it is acknowledged. \textit{Note that this ofcourse is not the same trame as sent. Therefore the confirmation trame must contain some sort of unique identifier. (e.g. a pair<moduleID,creationDate>)}
\end{itemize}
\subsection*{updatePrice}
\paragraph{Interface Identity} iCommandSender - updatePrice.
\paragraph{Resources provided} This method is used for the special pricing to make sure that dynamic remote modules can receive a price update and handle automatically to the change.
\begin{itemize}
\item Syntax: void updatePrice(Customer c, Price p)
\item Semantics: Based on the Customer the remote modules are looked up in the database. The Price is used in the command to notify the remote modules of the new price.
\end{itemize}
\subsection*{reconfigure}
\paragraph{Interface Identity} iCommandSender - reconfigure.
\paragraph{Resources provided} This interface is used to send a new configuration to a remote module.
\begin{itemize}
\item Syntax: void reconfigure(Module m, Configuration c)
\item Semantics: A reconfiguration command is created with the new configuration data for the given module and is passed to the Outgoing Communication Module.
\end{itemize}

\section*{Notification DB}
\subsection*{readNotificationData}
\paragraph{Interface Identity} iNotificationDB - readNotificationData.
\paragraph{Resources provided} Allows the Notification Handler to read the necessary data to send notifications to customers and ReMeS operators.
\begin{itemize}
\item Syntax: Data readNotificationData(Module m)
\item Semantics: The Modules data is requested from the database and returned in a Data object.
\end{itemize}
\subsection*{updateNotificationData}
\paragraph{Interface Identity} iNotificationDB - updateNotificationData.
\paragraph{Resources provided} Allow users to update their notification data in the database.
\begin{itemize}
\item Syntax: void updateNotificationData(Module m, Data d)
\item Semantics: The Data for that specific Module is updated or added in the database.
\end{itemize}

\section*{Main DB}
\subsection*{readData}
\paragraph{Interface Identity} iMainDB - readData.
\paragraph{Resources provided}  Read data from the database.
\begin{itemize}
\item Syntax: Data readData(Query q)
\item Semantics: Based on the Query, the database will return a specific Data result of the data that is requested.
\end{itemize}
\subsection*{storeData}
\paragraph{Interface Identity} iMainDB - storeData.
\paragraph{Resources provided} Store data in the database.
\begin{itemize}
\item Syntax: void storeData(Query q)
\item Semantics: The Query will update, add, delete, ... data in the database.
\end{itemize}

\section*{Data Processor}
\subsection*{processData}
\paragraph{Interface Identity} iDataProcessor - processData.
\paragraph{Resources provided} This interface will receive specific trames and send them to specific modules. For measurement trames it will send an ack, do anomaly detection and store the measurement in the database. For configuration trames it wilk send an ack and store it in the database.
\begin{itemize}
\item Syntax: void processData(Trame t)
\item Semantics: The Trame will be processed. First of all, for all Trames an Ack command is send. All trames are stored in the database and measurement trames are passed on for anomaly detection.
\end{itemize}

\section*{Anomaly Detector}
\subsection*{checkAnomaly}
\paragraph{Interface Identity} iAnomalyChecker - checkAnomaly.
\paragraph{Resources provided} This interface gives the ability to check trames for anomalies.
\begin{itemize}
\item Syntax: void checkAnomaly(Trame t)
\item Semantics: The trame is checked for possible anomalies. To do so, first the required data is retrieved from the Database, to load recent consumption history, consumption profiles, treshold paramaters, etc.
\end{itemize}

\section*{Billing Service}
\subsection*{markPaidBill}
\paragraph{Interface Identity} iBillingService - markPaidBill.
\paragraph{Resources provided} When a bill has been paid by the customer, the third party billing service can mark that bill as paid with this interface.
\begin{itemize}
\item Syntax: void markPaidBill(BillId id)
\item Semantics: The Bill with ID equal to the given BillId, will be marked as paid in the database.
\end{itemize}

\section*{UIS Interface}
\subsection*{requestConsumptionPrediction}
\paragraph{Interface Identity} iUISInterface - requestConsumptionPrediction.
\paragraph{Resources provided} The UIS can use this interface to request a consumption prediction.
\begin{itemize}
\item Syntax: Prediction requestConsumptionPrediction()
\item Semantics: Request the pre-calculated consumption prediction.
\item Syntax: Prediction requestConsumptionPrediction(Time t)
\item Semantics: Request a consumption prediction based on the given Time.
\end{itemize}
\subsection*{updatePrices}
\paragraph{Interface Identity} iUISInterface - updatePrices.
\paragraph{Resources provided} The UIS can use this interface to update the prices of their utilities.
\begin{itemize}
\item Syntax: void updatePrices(Price p)
\item Semantics: Update the Price of their utility.
\item Syntax: void updatePrices(Price p, Customer c)
\item Semantics: Update the Price for a specific Customer.
\end{itemize}

\section*{Consumption Predictor}
\subsection*{updateConsumptionPrediction}
\paragraph{Interface Identity} iConsPred - updateConsumptionPrediction.
\paragraph{Resources provided} When a new consumption prediction must be made, this interface can be used to call the process to do so. The returned prediction is distinct for each company.
\begin{itemize}
\item Syntax: Prediction updateConsumptionPrediction(Time t)
\item Semantics: Update the consumption prediction based on the specific Time, put it in the database and return the result. The returned prediction is distinct for each company. The company isn't given as a parameter cause we asumed in the design this would be possible to determine according the active session. Which will be created in the authentication phase.
\end{itemize}

\section*{Fraud Detection}
\subsection*{fraudDetected}
\paragraph{Interface Identity} iFraudDetection - fraudDetected.
\paragraph{Resources provided} Allows the Third Party Fraud Detection Service to notify ReMeS of a case of fraud.
\begin{itemize}
\item Syntax: void fraudDetected(FraudInfo f);
\item Semantics: Notifies a ReMeS operator that a case of fraud is detected for a Customer. FraudInfo contains the required info, as the suspected Customer, the related module(s), possibly complemented with a more detailed report when the fraud took place.
\end{itemize}

\section*{Customer Portal}
\subsection*{login}
\paragraph{Interface Identity} iCustomerPortal - login.
\paragraph{Resources provided} This interface authenticates a Customer.
\begin{itemize}
\item Syntax: void login(Credentials c);
\item Semantics: This interface identifies a given Customer (based on the provided credentials) in the system. 
From this point on the Customer may use all other interfaces provided by this component.
\end{itemize}
\subsection*{register}
\paragraph{Interface Identity} iCustomerPortal - register.
\paragraph{Resources provided} Allows for a new customer to register to the ReMeS System.
\begin{itemize}
\item Syntax: void register(Info i);
\item Semantics: A new customer is registered in the system. All relevant information is
added to the database. From this point on ReMeS modules can be linked to the customer's profile.
The customer receives a letter at a home address he has specified containing his login information.
\end{itemize}
\subsection*{unregister}
\paragraph{Interface Identity} iCustomerPortal - unregister.
\paragraph{Resources provided} Allows for a  customer to unregister to the ReMeS System.
\begin{itemize}
\item Syntax: void unregister(Customer c);
\item Semantics: unregister the Customer from the system.
\end{itemize}
\subsection*{customizeProfile}
\paragraph{Interface Identity} iCustomerPortal - customizeProfile.
\paragraph{Resources provided} Allows for a customer to customize his profile. Update his notification data, or update the measurement interval time, ...
\begin{itemize}
\item Syntax: void customizeProfile(Info i);
\item Semantics: Customizes the profile of the Customer according to the provided Info. Info is specified in getAccountInfo.
\end{itemize}
\subsection*{getAccountInfo}
\paragraph{Interface Identity} iCustomerPortal - getAccountInfo.
\paragraph{Resources provided} Allows the user to get his account information.
\begin{itemize}
\item Syntax: Info getAccountInfo(Customer c);
\item Semantics: Shows the account Info of the customer. Including contact information for notifications (e.g. SMS number, e-mail adress,etc), parameters for anomaly detection (e.g. thresholds), the Alarm Recipients and their respective contact information (e.g. SMS or E-Mail).
\end{itemize}

\section*{Operator Portal}
\subsection*{login}
\paragraph{Interface Identity} iOperatorPortal - login.
\paragraph{Resources provided} This interface authenticates a Operator.
\begin{itemize}
\item Syntax: void login(Credentials c);
\item Semantics: This interface identifies a given Operator (based on the provided credentials) in the system. 
From this point on the Operator may use all other interfaces provided by this component.
\end{itemize}
\subsection*{linkDevice}
\paragraph{Interface Identity} iOperatorPortal - linkDevice.
\paragraph{Resources provided} Link a customer to a remote device.
\begin{itemize}
\item Syntax: void linkDevice(Customer c, Device d);
\item Semantics: Links the Customer to the Device in the database.
\end{itemize}
register(CustomerInfo c)
\subsection*{register}
\paragraph{Interface Identity} iOperatorPortal - register.
\paragraph{Resources provided} Provides the operator with an interface to register a new user to the system.
\begin{itemize}
\item Syntax: void register(Info i);
\item Semantics: The operator adds the new customers info i and registers the customer to the ReMeS system. 
\end{itemize}

\section*{Researcher Portal}
\subsection*{login}
\paragraph{Interface Identity} iResearcherPortal - login.
\paragraph{Resources provided} This interface authenticates a Researcher.
\begin{itemize}
\item Syntax: void login(Credentials c);
\item Semantics: This interface identifies a given Researcher (based on the provided credentials) in the system. 
From this point on the Researcher may use all other interfaces provided by this component.
\end{itemize}

\subsection*{getStatistics}
\paragraph{Interface Identity} iResearcherPortal - getStatistics.
\paragraph{Resources provided} Link a customer to a remote device.
\begin{itemize}
\item Syntax: Stats getStatistics(Query q);
\item Semantics: Returns Statistics based on the Query
\end{itemize}

\section*{Statistics}
\subsection*{getStatistics}
\paragraph{Interface Identity} iStatistics - getStatistics.
\paragraph{Resources provided} Get statistics from the database. This is both for the customers as for researchers.
\begin{itemize}
\item Syntax: Stats getStatistics();
\item Semantics: Returns Stats for the customer
\item Syntax: Stats getStatistics(Query q);
\item Semantics: Returns Statistics for the researcher based on his Query. This interface is only for the researcher. This component is capable of anonimizing the statistics before returning them to the Researcher Portal.
\end{itemize}